import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
	list = '/journey/bsTravelgroupTourorderrecord/list',
	listByMainId = '/journey/bsTravelgroupTourorderrecord/listByMainId',
	postUpdateUpCarAddress = '/journey/bsTravelgroupTourorderrecord/changePickupPoin',
	exportXlsToTravelAgency = '/journey/bsTravelgroupTourorderrecord/exportXlsToTravelAgency',
	combinedPickupPoin = '/journey/bsTravelgroupTourorderrecord/combinedPickupPoin',
	save = '/journey/bsTravelgroupTourorderrecord/add',
	addOrderByOther = '/journey/bsTravelgroupTourorderrecord/addOrderByOther',
	edit = '/journey/bsTravelgroupTourorderrecord/edit',
	deleteOne = '/journey/bsTravelgroupTourorderrecord/delete',
	deleteBatch = '/journey/bsTravelgroupTourorderrecord/deleteBatch',
	importExcel = '/journey/bsTravelgroupTourorderrecord/importExcel',
	exportXls = '/journey/bsTravelgroupTourorderrecord/exportXls',
	refund = '/journey/bsTravelgroupTourorderrecord/refund',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
	defHttp.get({ url: Api.list, params });


export const listByMainId = (params) =>
	defHttp.get({ url: Api.listByMainId, params });

export const refundOrCancelJounery = (params) => {
	return defHttp.post({ url: Api.refund, params });
}
/**
 * 导出数据到Excel
 */
export const exportXlsToTravelAgency = (params) => {
	return defHttp.post({ url: Api.exportXlsToTravelAgency, params });
}
export const combinedPickupPoin = (params) => {
	return defHttp.post({ url: Api.combinedPickupPoin, params });
}
/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {

	if (!isUpdate) {
		params.signcontract = false
	}
	let url = isUpdate ? Api.edit : Api.save;
	return defHttp.post({ url: url, params });
}


export const postUpdateUpCarAddress = (params) => {

	return defHttp.post({ url: Api.postUpdateUpCarAddress, params });
}


export const addOrderByOther = (params) => {

	return defHttp.post({ url: Api.addOrderByOther, params });
}